import { ref } from 'vue';
import { defineStore } from 'pinia';
import { useLocalStorage } from '@vueuse/core';

export const useCartListStore = defineStore('cartList', () => {
  const cartListStore = useLocalStorage('cart-list', []);
  const cartList = ref(cartListStore.value);

  function addToCartList(product) {
    cartList.value = [...cartList.value, product];
  }

  return { cartList, addToCartList };
});
